<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>课程教学总结</title>
    <link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container mt-5">
        <div class="row">
            <div class="col-lg-8 offset-lg-2">
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">课程教学总结导入</h3>
                    </div>
                    <div class="card-body">
                        <div th:if="${error}" class="alert alert-danger" role="alert">
                            <p th:text="${error}"></p>
                        </div>
                        
                        <form method="POST" enctype="multipart/form-data" th:action="@{/import}">
                            <div class="mb-3">
                                <label for="file" class="form-label">选择ZIP格式的压缩文件</label>
                                <input type="file" class="form-control" id="file" name="file" accept=".zip" required>
                                <div class="form-text">支持的文件格式：.zip (包含Excel课程总结文件)</div>
                            </div>
                            
                            <div class="d-grid gap-2">
                                <button type="submit" class="btn btn-primary">上传并导入</button>
                                <a href="/" class="btn btn-secondary">返回首页</a>
                            </div>
                        </form>
                    </div>
                </div>
                
                <!-- 新增Excel汇总表导入卡片 -->
                <div class="card mt-4">
                    <div class="card-header bg-success text-white">
                        <h5 class="mb-0">Excel汇总表导入</h5>
                    </div>
                    <div class="card-body">
                        <form action="/import" method="POST" enctype="multipart/form-data">
                            <div class="form-group mb-3">
                                <label for="semester">学期</label>
                                <input type="text" class="form-control" id="semester" name="semester" 
                                       placeholder="例如：2022-2023-1" required>
                                <div class="form-text">请输入本批数据的学期信息</div>
                            </div>
                            <div class="form-group mb-3">
                                <label for="excelFile">选择Excel汇总表</label>
                                <input type="file" class="form-control" id="excelFile" name="excelFile" 
                                       accept=".xlsx,.xls" required>
                                <div class="form-text">
                                    Excel列顺序：教员、课程、班级、教学方法、形成性考核分析、试卷分析、成绩分析、课程教学总结、意见建议
                                </div>
                            </div>
                            <button type="submit" class="btn btn-success">导入汇总表</button>
                        </form>
                    </div>
                </div>
                
                <!-- 导入成功信息显示 -->
                <div th:if="${importSuccess}" class="card mt-4">
                    <div class="card-header bg-success text-white">
                        <h5 class="mb-0">导入成功</h5>
                    </div>
                    <div class="card-body">
                        <div class="alert alert-success">
                            <h5>成功导入以下数据：</h5>
                            <p><strong>学期：</strong> <span th:text="${semester}"></span></p>
                            <p><strong>导入总数：</strong> <span th:text="${importCount}"></span> 条记录</p>
                        </div>
                        
                        <div class="table-responsive" th:if="${importedData != null && !importedData.empty}">
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>教员</th>
                                        <th>课程</th>
                                        <th>班级</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr th:each="item, stat : ${importedData}">
                                        <td th:text="${stat.count}"></td>
                                        <td th:text="${item.teacher}"></td>
                                        <td th:text="${item.course}"></td>
                                        <td th:text="${item.className}"></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                
                <div class="mt-4">
                    <a href="/" class="btn btn-secondary">返回首页</a>
                </div>
                
                <div th:if="${error}" class="alert alert-danger mt-3">
                    <p th:text="${error}"></p>
                </div>
            </div>
        </div>
    </div>
    <script src="/assets/bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>